package cn.imjzm.runcarserve.service.impl;

import cn.imjzm.runcarserve.mapper.HomeMapper;
import cn.imjzm.runcarserve.pojo.User;
import cn.imjzm.runcarserve.pojo.carinformation;
import cn.imjzm.runcarserve.pojo.news;
import cn.imjzm.runcarserve.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class HomeServiceImpl implements HomeService {

    @Autowired
    public HomeMapper homeMapper;

    /**
     * 查询电量、信号、温度
     */
    @Override
    public carinformation selectCarInfo(Integer uId) {
        return homeMapper.selectCarInfo(uId);
    }

    /**
     * 查询消息通知
     */
    @Override
    @Transactional
    public List<news> getNewList(String email) {
        return homeMapper.getNews(email);
    }

    /**
     * 修改用户信息（参数回显）
     * @param id
     * @return
     */
    @Override
    public User getHome(int id) {
        return homeMapper.selectById(id);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    @Override
    public void update(User user) {
        //修改用户名
        homeMapper.update(user);
    }

    @Override
    public void updateCarName(User carName) {
        //修改车名
        homeMapper.updateCarName(carName);
    }
}
